import 'package:adaptive_dialog/adaptive_dialog.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:get/get.dart';
import 'package:mtf/R.dart';
import 'package:mtf/app/modules/mine_info_module/mine_info_controller.dart';
import 'package:mtf/app/theme/app_colors.dart';
import 'package:mtf/app/widget/AppBarLeftTitle.dart';
import 'package:mtf/app/widget/SettingBar.dart';
/**
 * GetX Template Generator - fb.com/htngu.99
 * */

class mineInfoPage extends GetView<mineInfoController> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBarLeftTitle(
        title: '个人资料',
      ),
      body: Container(
        child: ListView.builder(
          itemBuilder: (context, index) {
            if (index == 0) {
              return Container(
                margin: EdgeInsets.all(10),
                decoration: BoxDecoration(
                    color: Colors.white,
                    borderRadius: BorderRadius.circular(10)),
                child: Column(
                  children: [
                    Padding(
                      padding: const EdgeInsets.symmetric(
                          vertical: 15, horizontal: 10),
                      child: InkWell(
                        onTap: () {
                          controller.clickUpdateImage();
                        },
                        child: Flex(
                          direction: Axis.horizontal,
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Text("头像"),
                            Row(
                              children: [
                                Obx(() {
                                  return ClipOval(
                                      child: Image.network(
                                        controller.user.value.headUrl ??
                                            "https://via.placeholder.com/52x52",
                                        height: 52,
                                        width: 52,
                                        fit: BoxFit.fill,
                                      ));
                                }),
                                SizedBox(width: 5),
                                SvgPicture.asset(
                                  R.assetsImgIcSvgRight,
                                  width: 16,
                                  height: 16,
                                )
                              ],
                            )
                          ],
                        ),
                      ),
                    ),
                    Divider(
                      height: 1,
                    ),
                    Obx(() {
                      return SettingBar(
                        onTap: () {
                          controller.clickEditName();
                        },
                        paddingHorizontal: 10,
                        leftIconSpace: 0,
                        leftTextColor: c_666666,
                        rightTextColor: c_333333,
                        leftText: "昵称",
                        rightText: controller.user.value.nikname ?? "",
                        rightIcon: SvgPicture.asset(
                          R.assetsImgIcSvgRight,
                          color: c_999999,
                        ),
                        showDivider: true,
                      );
                    }),
                    SettingBar(
                      paddingHorizontal: 10,
                      leftIconSpace: 0,
                      leftTextColor: c_666666,
                      rightTextColor: c_333333,
                      leftText: "ID号",
                      rightText: "${controller.user.value.id.toString()}",
                      showDivider: true,
                    ),
                    Obx(() {
                      return SettingBar(
                        onTap: () {
                          controller.clickEditEmail();
                        },
                        paddingHorizontal: 10,
                        leftIconSpace: 0,
                        leftTextColor: c_666666,
                        rightTextColor: c_333333,
                        leftText: "电子邮箱",
                        rightText: "${controller.user.value.mailbox ?? ""}",
                        rightIcon: SvgPicture.asset(
                          R.assetsImgIcSvgRight,
                          color: c_999999,
                        ),
                        showDivider: true,
                      );
                    }),
                    Obx(() {
                      return SettingBar(
                        paddingHorizontal: 10,
                        leftIconSpace: 0,
                        leftTextColor: c_666666,
                        rightTextColor: c_333333,
                        leftText: "实名认证",
                        rightText: "${controller.user.value.authStatusStr()}",
                        showDivider: true,
                      );
                    })
                  ],
                ),
              );
            } else {
              // return Container(
              //   margin: const EdgeInsets.only(top: 30, left: 10, right: 10),
              //   width: double.maxFinite,
              //   height: 48,
              //   decoration: BoxDecoration(
              //     borderRadius: BorderRadius.circular(24),
              //     color: c_f12f38,
              //   ),
              //   child: TextButton(
              //       child: Text("保存",
              //           style: TextStyle(
              //               color: Colors.white,
              //               fontSize: 16,
              //               fontWeight: FontWeight.bold)),
              //       onPressed: () {}),
              // );
            }
          },
          shrinkWrap: true,
          itemCount: 2,
        ),
      ),
    );
  }

}
